#[derive(Debug)]

struct Rectangle{
    width: u32,
    height: u32,
}

impl Rectangle{
    fn area(&self)->u32{
        self.width * self.height
    }
}

fn main() {
    println!("Hello, world!");

    let width1 = 30;
    let height1 = 50;

    println!("面积是{}", area(width1, height1));

    //元组方式
    let rect1 = (30, 50);
    println!("rect1面积是{}", area1(rect1));

    //结构体方式
    let rect2 = Rectangle{
        width:30,
        height:59,
    };
    println!("rect2是{:#?}", rect2);
    println!("rect2面积是{}", area2(&rect2));
    println!("rect2面积是{}", rect2.area());

}


fn area(width:u32, height:u32)->u32{
    width * height
}

fn area1(dimensions:(u32, u32))->u32{
    dimensions.0 * dimensions.1
}

fn area2(rect:&Rectangle)->u32{
    rect.width * rect.height
}